<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<title></title>
	<link rel="stylesheet" href="">
</head>
<body>
<script type="text/javascript">
	var arr = [{
			days: "2018-11-28",
			id: 166,
			img: "http://modelplus.wx-plus.cn/public/upload/img/20181101/cdb5b0718adc5f96995adae7a728a744.jpg",
			model_id: 2,
			name: "神经病",
			status: 1,
			times: "11:00、12:00",
			user_id: 3
		}, 
		{
			days: "2018-11-28",
			id: 168,
			img: "http://modelplus.wx-plus.cn/public/upload/img/20181101/cdb5b0718adc5f96995adae7a728a744.jpg",
			model_id: 2,
			name: "神经病",
			status: 1,
			times: "9:00、10:00",
			user_id: 3,
		},
		{
			days: "2018-11-28",
			id: 168,
			img: "http://modelplus.wx-plus.cn/public/upload/img/20181101/cdb5b0718adc5f96995adae7a728a744.jpg",
			model_id: 2,
			name: "神经病",
			status: 1,
			times: "16:00、17:00",
			user_id: 3,
		},  
		{
			days: "2018-11-28",
			id: 168,
			img: "http://modelplus.wx-plus.cn/public/upload/img/20181101/cdb5b0718adc5f96995adae7a728a744.jpg",
			model_id: 2,
			name: "神经病",
			status: 1,
			times: "14:00、15:00",
			user_id: 3,
		}, 
		{
			days: "2018-11-28",
			id: 168,
			img: "http://modelplus.wx-plus.cn/public/upload/img/20181101/cdb5b0718adc5f96995adae7a728a744.jpg",
			model_id: 2,
			name: "神经病",
			status: 1,
			times: "16:00、17:00、18:00",
			user_id: 3,
		},
		{
			days: "2018-12-03",
			id: 161,
			img: "http://modelplus.wx-plus.cn/public/upload/img/20181101/cdb5b0718adc5f96995adae7a728a744.jpg",
			model_id: 2,
			name: "神经病",
			status: 1,
			times: "10:00",
			user_id: 3,
		}, 
		{
			days: "2018-12-03",
			id: 161,
			img: "http://modelplus.wx-plus.cn/public/upload/img/20181101/cdb5b0718adc5f96995adae7a728a744.jpg",
			model_id: 2,
			name: "神经病",
			status: 1,
			times: "11:00、12:00",
			user_id: 3,
		}, 
		{
			days: "2018-12-03",
			id: 161,
			img: "http://modelplus.wx-plus.cn/public/upload/img/20181101/cdb5b0718adc5f96995adae7a728a744.jpg",
			model_id: 2,
			name: "神经病",
			status: 1,
			times: "13:00、14:00",
			user_id: 3,
		}, 
		{
			days: "2018-11-23",
			id: 150,
			img: "http://modelplus.wx-plus.cn/public/upload/img/20181101/f27cd3716e375070a335eb8203a8d9ec.png",
			model_id: 11,
			name: "大小兄弟",
			status: 1,
			times: "9:00、10:00、11:00",
			user_id: 3,
		}, 
		{
			days: "2018-11-23",
			id: 150,
			img: "http://modelplus.wx-plus.cn/public/upload/img/20181101/f27cd3716e375070a335eb8203a8d9ec.png",
			model_id: 11,
			name: "大小兄弟",
			status: 1,
			times: "12:00、13:00、14:00",
			user_id: 3,
		}, 
		{
			days: "2018-11-24",
			id: 149,
			img: "http://modelplus.wx-plus.cn/public/upload/img/20181101/f27cd3716e375070a335eb8203a8d9ec.png",
			model_id: 11,
			name: "大小兄弟",
			status: 1,
			times: "10:00、16:00、21:00",
			user_id: 3,
		}, 
		{
			days: "2018-12-04",
			id: 162,
			img: "http://modelplus.wx-plus.cn/public/upload/img/20181101/f27cd3716e375070a335eb8203a8d9ec.png",
			model_id: 11,
			name: "大小兄弟",
			status: 1,
			times: "9:00",
			user_id: 3,
		}]


		// var arr = [
		//     {"id":"1001","name":"值1","value":"111"},
		//     {"id":"1001","name":"值1","value":"11111"},
		//     {"id":"1002","name":"值2","value":"25462"},
		//     {"id":"1002","name":"值2","value":"23131"},
		//     {"id":"1002","name":"值2","value":"2315432"},
		//     {"id":"1003","name":"值3","value":"333333"}
		// ];
		 
		var map = {},
		    dest = [];
		for(var i = 0; i < arr.length; i++){
		    var ai = arr[i];
		    if(!map[ai.model_id]){
		        dest.push({
		            id: ai.id,
		            name: ai.name,
		            ai.days: [ai]
		        });
		        map[ai.model_id] = ai;
		    }else{
		        for(var j = 0; j < dest.length; j++){
		            var dj = dest[j];
		            if(dj.model_id == ai.model_id){
		                dj.data.push(ai);
		                break;
		            }
		        }
		    }
}
 
console.log(dest);
</script>	
</body>
</html>